//
//  firstTableViewCell.swift
//  WaiBao
//
//  Created by 赵佟越 on 17/5/13.
//  Copyright © 2017年 zhaotongyue. All rights reserved.
//

import UIKit

class firstTableViewCell: UITableViewCell {
    private var tempModel:GongSiModel!
    var titleLabel:UILabel?
    var picImgView:UIImageView?
    
    required init?(coder aDecoder:NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override init(style:UITableViewCellStyle, reuseIdentifier:String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.setUpUI();
    }
    
    func setUpUI() {
        self.titleLabel = UILabel.init()
        self.addSubview(self.titleLabel!)
        self.picImgView = UIImageView()
        self.addSubview(self.picImgView!)
    }
    
    override func layoutSubviews() {
        self.picImgView?.snp.makeConstraints({ (make) in
            make.top.equalTo(self).offset(40)
            make.right.left.equalTo(self)
            make.bottom.equalTo(self).offset(-10)
        })
        self.picImgView?.layer.cornerRadius = 10
        self.picImgView?.backgroundColor = UIColor.lightGray
        self.picImgView?.image = UIImage.init(named: "a")
        self.titleLabel?.backgroundColor = UIColor.clear;
        self.titleLabel?.frame = CGRect(x:0, y:0, width:100, height:30)
        self.titleLabel?.textColor = UIColor.black
        self.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        self.titleLabel?.textAlignment = NSTextAlignment.center
    }
    var model : GongSiModel {
        set {
            tempModel = newValue
            self.titleLabel?.text = tempModel?.name
            //在这里给cell里的属性赋值
        }
        get {
            return (self.tempModel)!
        }
    }
    // 自定义cell 高度
    func heightForCell(status:GongSiModel)->(CGFloat){
        //设置数据
        self.model = status
        //刷新布局
        self.layoutIfNeeded()
        //返回最最下方控件的最大Y值，就是高度啦
        return  picImgView!.frame.maxY
    }
   

}
